package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.financing.wap.common.BizEnums.CommonEnums;
import com.financing.wap.dao.IFpClientActivityDao;
import com.financing.wap.dto.FpClientActivityDTO;
import com.financing.wap.service.IFpClientActivityService;
import com.financing.wap.util.DTOdateSetUtil;
/**
 * fp_client_activity  
 * 客户的活动表 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Repository("fpClientActivityService")
public class FpClientActivityServiceImpl implements IFpClientActivityService{

	@Autowired
	private IFpClientActivityDao fpClientActivityDao;

	@Override
	public int insert(FpClientActivityDTO fpClientActivity) throws SQLException {
		DTOdateSetUtil.setCreateInfo(fpClientActivity);
		DTOdateSetUtil.setUpdateInfo(fpClientActivity);
		fpClientActivity.setDeleteTag(CommonEnums.VALID_FLAG_1);
		return fpClientActivityDao.insert(fpClientActivity);
	}

	@Override
	public void update(FpClientActivityDTO fpClientActivity) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(fpClientActivity);
		fpClientActivityDao.update(fpClientActivity);
	}

	@Override
	public void updateForce(FpClientActivityDTO fpClientActivity) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(fpClientActivity);
		fpClientActivityDao.updateForce(fpClientActivity);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		fpClientActivityDao.delete(id);
	}
	
	@Override
	public List<FpClientActivityDTO> queryList(FpClientActivityDTO fpClientActivity) throws SQLException {
		return fpClientActivityDao.queryList(fpClientActivity);
	}

	@Override
	public int queryListCount(FpClientActivityDTO fpClientActivity) throws SQLException {
		return fpClientActivityDao.queryListCount(fpClientActivity);
	}

	@Override
	public FpClientActivityDTO loadById(Integer id) throws SQLException {
		return fpClientActivityDao.loadById(id);
	}
 	@Override
	public FpClientActivityDTO queryListGetFirst(FpClientActivityDTO fpClientActivity)
			throws SQLException {
		 List<FpClientActivityDTO> queryList = queryList(fpClientActivity);
		 if(queryList==null||queryList.size()==0){
			 return new FpClientActivityDTO();
		 }
		 return queryList.get(0);
	}
}
